package com.skydonkey.dao;


import com.github.pagehelper.Page;
import com.skydonkey.pojo.po.VideoWatchHistory;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface VideoWatchHistoryMapper {

    @Insert("INSERT INTO videos_watch_history (uid, video_id) VALUES (#{uid}, #{videoId})")
    @Options(useGeneratedKeys = true, keyProperty = "recordId")
    int insertWatchHistoryVideo(VideoWatchHistory videoWatchHistory);

    @Delete("DELETE FROM videos_watch_history WHERE video_id = #{videoId} and uid = #{uid}")
    int deleteWatchHistoryVideo(VideoWatchHistory videoWatchHistory);

    @Select("SELECT * FROM videos_watch_history WHERE uid = #{uid} order by create_time desc ")
    Page<VideoWatchHistory> getWatchHistoryVideosByUid(Long uid);

    @Select("SELECT COUNT(1) FROM videos_watch_history WHERE uid = #{uid} ")
    int getHistoryCount(Long uid);

}
